package com.ryl.yomall.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ryl.yomall.model.common.util.MD5;
import com.ryl.yomall.model.user.UserInfo;
import com.ryl.yomall.user.mapper.UserInfoMapper;
import com.ryl.yomall.user.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Date 21:29
 * @Author ryl
 */
@Service
public class LoginServiceImpl implements LoginService {
    @Autowired
    private UserInfoMapper userInfoMapper;

    /**
     * 查询用户名和密码
     */
    @Override
    public UserInfo login(UserInfo userInfo) {

        return  userInfoMapper.selectOne ( new QueryWrapper<UserInfo> (  )
                .eq ( "login_name",userInfo.getLoginName () )
                .eq ( "passwd",MD5.encrypt ( userInfo.getPasswd () ) ));
    }

    @Override
    public void register(UserInfo userInfo) {
        userInfoMapper.insert ( userInfo );
    }
}
